///
/// If `plugin` is true, the pair corresponds to the host platform,
/// otherwise it corresponds to the target platform.
- fn staticlib(&self, kind: Kind) -> CargoResult<(&str, &str)> {
+ pub fn staticlib(&self, kind: Kind) -> CargoResult<(&str, &str)> {
let (triple, pair) = if kind == Kind::Host {
(&self.config.rustc_info().host, &self.host_staticlib)
} else {
let layout = cx.layout(unit.pkg, unit.kind);
for filename in try!(cx.target_filenames(unit)) {
- if filename.ends_with(".a") { continue }
+ if let Ok((prefix, suffix)) = cx.staticlib(unit.kind) {
+ if filename.starts_with(prefix) && filename.ends_with(suffix) {
+ continue
+ }
+ }
let mut v = OsString::new();
v.push(&unit.target.crate_name());
v.push("=");
[lib]
name = "foo"
- crate-type = ["staticlib", "dylib", "rlib"]
+ crate-type = ["dylib", "rlib"]
"#)
.file("src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
- assert_that(&p.root().join("target/debug/libfoo.a"), existing_file());
assert_that(&p.root().join("target/debug/libfoo.rlib"), existing_file());
let dylib_name = format!("{}foo{}", env::consts::DLL_PREFIX,
env::consts::DLL_SUFFIX);
"#)
.file("bar/src/lib.rs", r#"
pub fn bar() {
- #[link(name = "builder")]
+ #[cfg_attr(not(target_env = "msvc"), link(name = "builder"))]
+ #[cfg_attr(target_env = "msvc", link(name = "builder.dll"))]
extern { fn foo(); }
unsafe { foo() }
}
.display());
}
"#)
- .file("bar/src/lib.rs", &format!(r#"
+ .file("bar/src/lib.rs", r#"
#![feature(plugin_registrar, rustc_private)]
extern crate rustc_plugin;
use rustc_plugin::Registry;
- #[link(name = "{}")]
- extern {{ fn foo(); }}
+ #[cfg_attr(not(target_env = "msvc"), link(name = "builder"))]
+ #[cfg_attr(target_env = "msvc", link(name = "builder.dll"))]
+ extern { fn foo(); }
#[plugin_registrar]
- pub fn bar(_reg: &mut Registry) {{
- unsafe {{ foo() }}
- }}
- "#, libname));
+ pub fn bar(_reg: &mut Registry) {
+ unsafe { foo() }
+ }
+ "#);
assert_that(foo.cargo_process("build").env("SRC", &lib).arg("-v"),
execs().with_status(0));